import { modal } from 'vue-strap'
import DatePicker from 'vue-datepicker'
import getDatePickerOption from '../../../../util/date-picker-option'
import { getNow, getFirstTimeOfYear } from '../../../../util/moment'
import { showMsg, exportPayPromotert } from '../../../../vuex/action'

export default {
  name: 'code-excel',
  data() {
    return {
      title: '确认支付',
      datePickerOption: getDatePickerOption(),
      status: 4,
      startTime: getFirstTimeOfYear(),
      endTime: getNow()
    }
  },
  props: ['showPay'],
  components: {
    'vue-modal': modal,
    'vue-date-picker': DatePicker
  },
  vuex: {
    actions: {
      xShowMsg: showMsg,
      xExportPayPromotert: exportPayPromotert
    }
  },
  methods: {
    showImportExcel() {
      this.showPay = true
    },
    submit() {
      var params = {
        status: this.status,
        startTime: this.startTime,
        endTime: this.endTime
      }
      this.xExportPayPromotert(params)
        .then((data) => {
          this.showPay = false
          this.xShowMsg({
            type: 'info',
            content: '操作成功'
          })
        })
        .catch((res) => {
          this.xShowMsg({
            type: 'danger',
            content: res.error_msg
          })
        })
    }
  }
}
